package com.xcm.dao;

import com.github.pagehelper.Page;
import com.xcm.model.SysDepartment;
import com.xcm.model.vo.SysDepartmentVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 部门持久层
 *
 * @author linqiang
 * @date 2018-04-13 9:15
 */
public interface SysDepartmentMapper extends BaseMapper<SysDepartment> {

    /**
     * 列表分页
     *
     * @param paramMap 参数
     * @return
     */
    Page<SysDepartmentVo> listPage(Map<String, Object> paramMap);

    /**
     * 查询集合
     *
     * @param paramMap 参数map
     * @return
     */
    List<SysDepartmentVo> list(Map<String, Object> paramMap);

    /**
     * 根据id查询
     *
     * @param id 部门id
     * @return
     */
    SysDepartmentVo getByIdVo(@Param("id") Integer id);

    /**
     * 根据名称查询
     *
     * @param departmentName 部门名称
     * @return
     */
    SysDepartment getByName(@Param("departmentName") String departmentName);

    /**
     * 根据父id统计子部门数量
     *
     * @param parentId
     * @return
     */
    Integer countByParentId(@Param("parentId") Integer parentId);

    /**
     * 插入并返回影响行数
     *
     * @param sysDepartment
     * @return
     */
    int saveAndGetId(SysDepartment sysDepartment);

    /**
     * 批量删除
     *
     * @param departmentIdSet id集合
     * @return
     */
    int batchDelete(@Param("departmentIdSet") Set<Integer> departmentIdSet);
}
